package cn.com.sinosoft.testxmltransform.yewu;

import java.util.ArrayList;
import java.util.List;

import cn.com.sinosoft.testxmltransform.Child;


/**
 * 机构集合传输类
 * @author lianWuJun
 * @time   2017年2月10日 上午10:31:44
 */
@Child(clazz = { Organization.class })
public class Organizations {

	private List<Organization> organizationList = new ArrayList<Organization>();

	public List<Organization> getOrganizationList() {
		return organizationList;
	}

	public void setOrganizationList(List<Organization> organizationList) {
		this.organizationList = organizationList;
	}
	
	/**
	 * 数据转换
	 * 传输类转实体类
	 * @return	List集合
	 */
    public List<OrganizationEntity> toOrganizationEntityList(){
    	List<OrganizationEntity> organizationEntities = new ArrayList<OrganizationEntity>();
    	if(this.organizationList != null && this.organizationList.size() > 0){
		    	int size = this.organizationList.size();				
				for(int i = 0;i < size;i++){
					Organization organization = this.organizationList.get(i);
					OrganizationEntity organizationEntity = organization.toOrganizationEntity();
					
					List<DepartmentEntity> departmentEntities=organization.toDepartmentEntityList();
					organizationEntity.setDepartmentList(departmentEntities);
					organizationEntities.add(organizationEntity);
				}
    	}
		return organizationEntities;
    }
    
    public void addOrganization(Organization organization){
    	this.organizationList.add(organization);
    }
} 
